package someTestExcemple.huaweiOd.container.mapAndList;
import java.util.*;
//https://blog.csdn.net/guorui_java/article/details/131906923
//华为OD机试 - 告警抑制 - 数据结构map（Java 2025 A卷 100分）
public class AlertInhibition {
    //TODO 还没做完
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.nextLine());
        //key-告警名 value-可被抑制的告警
        Map<String,HashSet<String>> map = new HashMap<>();
        //最后实际产生的告警
        Stack<String> stackResult = new Stack<>();
        for(int i = 0; i < n; i++) {
            String[] str = sc.nextLine().split(" ");
            if(!map.get(str[0]).isEmpty()) {
                map.get(str[0]).add(str[1]);
            } else {
                Set<String> set = new HashSet<>();
                set.add(str[1]);
                map.put(str[0], (HashSet<String>) set);
            }
        }
        //告警表
        String[] warnings = sc.nextLine().split(" ");
        sc.close();
        //String cur = warnings[0];
        stackResult.push(warnings[0]);
        for(int i = 1; i < warnings.length; i++) {
            if(!map.get(stackResult.peek()).contains(warnings[i])) {
                //当前告警没被抑制
                if(map.get(warnings[i]).contains(stackResult.peek())) {
                    //当前告警抑制前一个告警
                }
            }
        }
    }
}
